import java.util.Scanner;

public class 最低通行费 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int[][] w = new int[N + 1][N + 1];
        int[][] f = new int[N + 1][N + 1];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                w[i][j] = scan.nextInt();
            }
        }

        //开始动态规划
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                if (i == 1 && j == 1)
                    f[i][j] = w[i][j];
                else {
                    f[i][j] = 100000000;
                    if (i > 1) f[i][j] = Math.min(f[i][j], f[i - 1][j] + w[i][j]);
                    if (j > 1) f[i][j] = Math.min(f[i][j], f[i][j - 1] + w[i][j]);
                }
            }
        }
        System.out.println(f[N][N]);
    }
}
